package space.sakana.edusysback.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import space.sakana.edusysback.entity.Admin;

@Mapper
public interface AdminMapper {

    @Select("select `id`, `username`, `password`, `token` from teacher where `id`=#{id};")
    Admin selectAdminById(int id);

    @Select("select `id`, `username`, `password`, `token` from teacher where `username`=#{username};")
    Admin selectAdminByUsername(String username);

    @Insert("insert into teacher(`username`, `password`) values(#{username}, #{password});")
    int insertAdmin(Admin admin);

    @Update("update teacher set `username`=#{username}, `password`=#{password}, `token`=#{token} where `id`=#{id};")
    int updateAdmin(Admin admin);

    @Select("select `id`, `username`, `password`, `token` from teacher where `token`=#{token};")
    Admin selectAdminByToken(String token);
}
